package com.tm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tm.mapper.EcStoreManageMapper;
import com.tm.model.EcStoreManage;
import com.tm.model.EcStoreManageCriteria;

@Service
public class EcStoreManageService {
	
	@Autowired
	private EcStoreManageMapper esmMapper;

	/**
	 * 获取门店列表
	 * @param areaId
	 * @return
	 */
	public List<EcStoreManage> getEcStoreManageList(String areaId) {
		
		EcStoreManageCriteria example = new EcStoreManageCriteria();
		example.createCriteria()/*.andAreaIdEqualTo(areaId)*/.andIsDeleteEqualTo("N");
		List<EcStoreManage> list = esmMapper.selectByExample(example);
		return list;
	}

	/**
	 * 根据会员id获取其代理的门店信息
	 * @param memberId
	 * @return
	 */
	public EcStoreManage getEcStoreManageByMemberId(Integer memberId) {
		
		EcStoreManageCriteria example = new EcStoreManageCriteria();
		example.createCriteria().andMemberInfoIdEqualTo(memberId).andIsDeleteEqualTo("N");
		List<EcStoreManage> list = esmMapper.selectByExample(example);
		if(list.size() > 0)
			return list.get(0);
		else
			return null;
	}

	/**
	 * 
	 * @param attribute
	 * @return
	 */
	public EcStoreManage getEcStoreManageByStoreId(Integer storeId) {
		return esmMapper.selectByPrimaryKey(storeId);
	}
	
	

}
